
from django.shortcuts import render
from .ana import ChipotleAna
import time

# #
# REMOTE_HOST = "https://pyecharts.github.io/assets/js"
# #
# #
# def index(request):
# #
#     chipo = ChipotleAna()
#
#     info = chipo.how_many_are_sold_per_item()
#
#     bar = chipo.echarts_bar(info.index, info.quantity)
#     # bar = chipo.bar_how_many_are_sold_per_item()
#
#     context = dict(
#
#         myechart=bar.render_embed(),
#
#         host=REMOTE_HOST,
#
#         script_list = bar.get_js_dependencies())
# #     )
# #     ti = time.time
# #     request.session['time'] = ti
#     return render(request,'index.html',context)

from django.shortcuts import render
from django.http import HttpResponse

from .ana import ChipotleAna

# Create your views here.

REMOTE_HOST = "https://pyecharts.github.io/assets/js"


def index(request):
    # html = '''\
    #
    #
    # <h1>XX 同学</h1>
    #
    # <hr>
    #
    # <h2>Chipotle 数据分析</h2>
    #
    # <div align = 'center'>
    #
    # <h3>
    #
    # <a href = '1/'>每种商品卖出个数</a> <br>
    #
    # <a href = '2/'>每个商品卖了多少钱</a><br>
    #
    # <a href = '3/'>每种商品的销售个数</a><br>
    #
    # <a href = '4/'>每种商品销售金额在流水总额中所占的比例</a><br>
    #
    # <a href = '5/'>每个商品销售金额以及个数</a><br>
    #
    # </h3>
    #
    # </div>
    #
    # <hr>
    #
    #
    #
    # '''

    return render(request,'first.html')


def index1(request):
    chipo = ChipotleAna()

    bar = chipo.bar_how_many_are_sold_per_item()

    # bar = chipo.echarts_bar(info.index, info.quantity)

    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'index.html', context)


def index2(request):
    chipo = ChipotleAna()

    bar = chipo.bar_how_much_are_sold_per_item()



    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'index.html', context)

def index3(request):

    chipo = ChipotleAna()

    bar = chipo.Nombre_de_ventes_par_type_de_produit()



    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'index.html', context)

def index4(request):

    chipo = ChipotleAna()

    bar = chipo.The_proportion_of_each_commodity_in_the_total_amount()

    # bar = chipo.echarts_bar(info.index, info.quantity)

    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'index.html', context)

def index5(request):

    chipo = ChipotleAna()

    bar = chipo.Montant_par_ordre()

    # bar = chipo.echarts_bar(info.index, info.quantity)

    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'index.html', context)


